package com.xpqh.ksg.modular.core.controller;

import com.xpqh.ksg.base.BaseController;
import com.xpqh.ksg.base.BaseResponseDTO;
import com.xpqh.ksg.modular.core.dto.*;
import com.xpqh.ksg.modular.core.service.CoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/ksg/core")
public class CoreController extends BaseController {


    @Autowired
    private CoreService coreService;
    @PostMapping("/brand")
    public BaseResponseDTO brand() {
        return renderResultOk(coreService.getBrandList());
    }

    @PostMapping("/brandGroup")
    public BaseResponseDTO brandGroup() {
        return renderResultOk(coreService.getBrandGroupList());
    }

    @PostMapping("/series")
    public BaseResponseDTO series(@Valid @RequestBody SeriesListReqDTO req) {
        return renderResultOk(coreService.series(req));
    }

    @PostMapping("/productNameList")
    public BaseResponseDTO productNameList( @Valid @RequestBody KsgProductNameListReqDTO req) {
            return renderResultOk(coreService.getProductNameList( req.getType(),req.getChannelType(),req.getProductType()));
    }

    @PostMapping("/priceInfo")
    public BaseResponseDTO priceInfo(@Valid @RequestBody KsgPriceListReqDTO req) {
        return renderResultOk(coreService.getPriceInfo( req.getCarSeriesId(), req.getProductId()));
    }

    @PostMapping("/windowTypeList")
    public BaseResponseDTO windowTypeList(KsgProductNameListReqDTO req) {
        return renderResultOk(coreService.getWindowTypeList(req.getChannelType()));
    }

    @PostMapping("/windowPrice")
    public BaseResponseDTO windowPrice(@Valid @RequestBody KsgWindowPriceReqDTO req) {
        return renderResultOk(coreService.getWindowPrice(req.getCarSeriesId(), req.getProductIdList()));
    }

    @PostMapping("/productSeriesList")
    public BaseResponseDTO productSeriesList(@Valid @RequestBody KsgProductSeriesListReqDTO req) {
        return renderResultOk(coreService.getProductSeriesList(req.getProductId()));
    }
    @PostMapping("/OCRVIN")
    public BaseResponseDTO OCRVIN(@Valid @RequestBody KsgOCRVINCReqDTO req) {
        return renderResultOk(coreService.ocrVIN(req.getPicture()));
    }

    @PostMapping("/barCode")
    public BaseResponseDTO barCode(@Valid @RequestBody KsgOCRVINCReqDTO req) {
        return renderResultOk(coreService.barCode(req.getPicture(),getUserId()));
    }

}

